<template>
  <div class="banner">
    <el-carousel :interval="3000" type="card" :initial-index="4" height="500px">
      <el-carousel-item v-for="item in data.arr" :key="item.id">
        <img :src="item.imageUrl" class="img" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import { getBanner } from "@/api";
import { reactive, onBeforeMount } from "vue";
export default {
  setup() {
    let data = reactive({ arr: [] });
    onBeforeMount(async () => {
      await getBanner().then((res) => {
        // console.log(res);
        if (res) {
          data.arr = res.data.banners;
        }
      });
    });
    return { data };
  },
};
</script>

<style scoped>
.banner {
  max-width: 90%;
  margin: 0 auto;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.img {
  width: 100%;
  height: 100%;
}

.is-active {
  transform: translateX(180px) scale(1) !important;
  width: 70%;
}
</style>
<style lang="less" scoped>
:deep(.el-carousel__arrow) i {
  font-size: 29px !important;
}
:deep(.el-carousel__arrow) {
  width: 64px !important;
  height: 64px !important;
  background: #909399;
  color: white;
  border-radius: 5px;
  opacity: 0.8;
}
:deep(.el-carousel__arrow:hover) {
  background: #606266;
}
:deep(.el-carousel__button){
  width:45px;
  height: 8px;
}
</style>
